import VueCookies from 'vue-cookies'
const app = {
	state: {
		token: VueCookies.get('sy_token'),
		avatar: VueCookies.get('sy_avatar'),
		nickName: VueCookies.get('sy_username'),
		userInfo: VueCookies.get('sy_userInfo'),
		links: []
	},
	mutations: {
		SET_TOKEN: (state, token) => {
			state.token = token
		},
		SET_AVATAR: (state, avatar) => {
			state.avatar = avatar
		},
		SET_NICKNAME: (state, nickName) => {
			state.nickName = nickName
		},
		SET_USERINFO: (state, userInfo) => {
			state.userInfo = userInfo
		},
		SET_LINKS: (state, links) => {
			state.links = links
		},
	},
	actions: {
		// GetInfo({commit, state}) {
		//   return new Promise((resolve, reject) => {
		//     getInfo().then(response => {
		//       const data = response.data
		//       commit('SET_NAME', data.userName)
		//       commit('SET_PERSONAUTHSTATUS', data.personAuthStatus)
		//       commit('SET_PHONE', data.phone)
		//       commit('SET_ISAGREEMENT', data.isAgreement)
		//       commit('SET_ISLOGIN', true)
		//       commit('SET_USERCODE',data.userCode)
		//       if(data.personAuth) {
		//         commit('SET_FULLNAME', data.personAuth.fullName)
		//         commit('SET_IDNUMBER', data.personAuth.idNumber)
		//         commit('SET_CREDATE', data.personAuth.creDate)
		//       }
		//       resolve(response)
		//     }).catch(error => {
		//       reject(error)
		//     })
		//   })
		// },
	}
}

export default app